import Order from './Order'
import OrderDetail from './OrderDetail'

class ObjectImpl<T extends object, K extends keyof T> {
  object!: T
  key!: K
  constructor(object_: T, key_: K) {
    this.object = object_
    this.key = key_
  }
  getValue() {
    return this.object[this.key]
  }
  setValue(newVal: T[K]) {
    this.object[this.key] = newVal
  }
}

let orderDetailOne = new OrderDetail(10, '电视机', 5000, 3)
let orderDetailTwo = new OrderDetail(11, '桌子', 2000, 2)
var orderDate = new Date(2023, 10, 17, 5, 20, 0)
let order = new Order(1, orderDate, '李武理', '33333', [
  orderDetailOne,
  orderDetailTwo,
])
let result = order['orderDetailArray']
console.log(result);

type OrderType = keyof Order

let objectImpl = new ObjectImpl<Order, 'phone'>(order, 'phone')
objectImpl.getValue()
// objectImpl.setValue('3')
